package spring.yongongsystem.mapper;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import spring.yongongsystem.POJO.dto.MerchantPageQueryDTO;
import spring.yongongsystem.POJO.entity.Merchant;


@Mapper
public interface MerchantMapper{
    /**
     * 分页查询
     * @param merchantPageQueryDTO
     * @return
     */
    Page<Merchant> pageQuery(MerchantPageQueryDTO merchantPageQueryDTO);

    @Delete("delete from unloading.merchant where merchant.merchant_id = #{merchantId}")
    void deleteById(Long id);

    @Select("select * from merchant where username = #{username}")
    Merchant getByUsername(String username);

    void update(Merchant merchant);
    @Insert("insert into merchant (username, password, phone, name)" +
            " VALUES" +
            " (#{username},#{password},#{phone},#{name})")
    void insert(Merchant merchants);

    @Select("SELECT COUNT(*) FROM merchant;")
    long count();
}